sortedUsers.forEach(userId => {
const userItem = document.createElement('div');
//userItem.className = 'online-user-item';
//4.21修改
userItem.className = `online-user-item ${userId === currentUserId ? 'current-user' : ''}`;

// 状态图标
const statusIcon = document.createElement('span');
statusIcon.className = 'user-status';
statusIcon.style.backgroundColor = '#28a745'; // 绿色表示在线

// 用户信息
const userInfo = document.createElement('div');
userInfo.className = 'user-info';

const userName = document.createElement('span');
userName.className = 'user-name';
userName.textContent = userId;

if (userId === currentUserId) {
userName.textContent += ' (我)';
userItem.classList.add('current-user');
}

userInfo.appendChild(userName);
userItem.appendChild(statusIcon);
userItem.appendChild(userInfo);

// 添加点击事件可以扩展私聊功能
userItem.addEventListener('click', () => {
// 这里可以扩展私聊功能
console.log('Start private chat with:', userId);
});